<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:insert="~{include :: header('入驻申请列表')}" />
    <th:block th:insert="~{include :: bootstrap-table-css}" />
</head>
<body class="hold-transition">
<div class="container-fluid mb-2">
    <div class="toolbar" id="toolbar" role="group">
        <form id="formId">
            <div class="form-inline">
                <input type="text" class="form-control mr-1" name="searchKey" placeholder="名称/手机">
                <select name="status" class="form-control mr-1">
                    <option value="">状态</option>
                    <option value="0">未审核</option>
                    <option value="1">已通过</option>
                    <option value="2">未通过</option>
                </select>
                <button type="button" class="btn btn-primary mr-1" onclick="$.table.search()">
                    <i class="fa fa-search"></i>
                    搜索
                </button>
                <button type="button" class="btn btn-default" onclick="$.form.reset()">
                    <i class="fa fa-refresh"></i>
                    重置
                </button>
            </div>
        </form>
    </div>
    <table id="bootstrap-table" class="table-striped"></table>
</div>
<th:block th:insert="~{include :: footer}" />
<th:block th:insert="~{include :: bootstrap-table-js}" />
<script th:inline="javascript">
    var prefix = "/teacher/apply";
    $(function() {
        var options;
        options = {
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            url: prefix + "/list.json",
            removeUrl: prefix + "/remove.json",
            modalName: "入驻申请",
            columns: [
                {
                    field: 'id',
                    title: 'id'
                },
                {
                    field: 'name',
                    title: '名称'
                },
                {
                    field: 'mobile',
                    title: '电话'
                },
                {
                    field: 'title',
                    title: '职称'
                },
                {
                    field: 'teachYear',
                    title: '教龄/年'
                },
                {
                    field: 'avatar',
                    title: '头像',
                    formatter: function (value, row, index) {
                        if (value === "" || value == null) {
                            return "<img class='img-circle img-xs' data-height='50' data-width='50' data-target='self' src='/static/img/user.png'/>"
                        } else {
                            return $.common.sprintf("<img class='img-circle img-xs' height='50' width='50' data-target='self' src='%s'/>",  value);
                        }
                    }
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        if (value === 0) {
                            return '<span class="badge badge-primary">未审核</span>'
                        } else if (value === 1) {
                            return '<span class="badge badge-success">已通过</span>'
                        } else if (value === 2) {
                            return '<span class="badge badge-danger">未通过</span>'
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '申请时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="applyInfo(\'' + row.id + '\')"><i class="fa fa-search"></i>详情</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    //优惠券详情
    function applyInfo(id) {
        layer.open({
            type: 2,
            area: ['65%', '90%'],
            fix: false,
            maxmin: true,
            shade: 0.3,
            title: "详情",
            content: "/teacher/apply/info.html?id=" + id
        });
    }
</script>
</body>
</html>